package com.vic.hello_world;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.vic.utils.RabbitmqUtils;

public class Consumer {

    private final static String QUEUE_NAME = "hello";

    public static void main(String[] argv) throws Exception {
        Channel channel = RabbitmqUtils.getChannel();

        // 消息处理
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody(), "UTF-8");
            System.out.println(" [x] Received '" + message + "'");
        };
        channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { });
    }
}